import 'whatwg-fetch'
function obj2params(obj) {
  let result = '';
  for (let item in obj) {
    result += '&' + item + '=' + encodeURIComponent(obj[item]);
  }

  if (result) {
    result = result.slice(1);
  }

  return result;
}

export function get(url,param,token) {
  if(param){
    url =url+"?"+ obj2params(param);
  }
  const result = fetch(url, {
    method: 'GET',
    headers: {
      'Accept': 'application/json, text/plain, */*',
      'Content-Type': 'application/x-www-form-urlencoded',
      'X-Auth-Token': 'Bearer '+token
    },
  });
  return result;
}
